import qs from 'querystring'
import request from '@/utils/request'

const GET_LIST = 'roles'
const EDIT_LIST = 'roles/'
const RIGHT_TYPE = 'rights/'


function getList(){
    return request({
        url:GET_LIST,
        method:'get'
    })
}
function addList(obj){
    return request({
        url:GET_LIST,
        method:'post',
        data:obj
    })
}
function editList(id){
    return request({
        url:EDIT_LIST + id,
        method:'get'
    })
}
function updateList(obj){
    return request({
        url:EDIT_LIST + obj.roleId,
        method:'put',
        data:obj
    })
}
function delRoles(id){
    return request({
        url:EDIT_LIST + id,
        method:'delete'
    })
}





function getRight(){
    return request({
        url:RIGHT_TYPE+'tree',
        methods:'get'
    })
}



function closeDel(a,b){
    return request({
        url:EDIT_LIST + a + '/rights/'  +b,
        method:'delete'
    })
}

function RolesTJ(id,arr){
    return request({
        url:EDIT_LIST + id +'/rights',
        method:'post',
        data:{rids:arr}

    })
}



export {getList,addList,editList,updateList,delRoles,getRight,closeDel,RolesTJ}